/**
 * \file kernel/canvas.h 
 */

#ifndef DODO_CANVAS_H
#define DODO_CANVAS_H

#include <string>
#include <dodo_plot/kernel/plotfwd.h>
#include <dodo_plot/kernel/plotter.h>
#include <cairomm/cairomm.h>

namespace dodo_plot
{

/**
 * Canvas is the stuff that actually draws the sketched pictures
 * It has absolute width and height
 * Pictures will be scaled to fit it.
 *
 * Routine is like this:
 *	- Design the Picture by using some widgets and combinating them.
 *	- Create a Canvas, and use its draw(picture) method.
 *	- Save it with write_png(filename) method.
 */
	
class Canvas
{
public:
	Canvas(int x = 800, int y = 600);
	~Canvas();

	void draw(const Picture& picture);
	void write_png(const std::string& filename) const;
	void resize(int new_x, int new_y);
	void resize_as(const Picture& picture);
	
	/// This is only used when you decide to use Cairo stuffs directly.
	inline Cairo::RefPtr<Cairo::Context> get_cr() { return cr_;}

	inline int x_size() const { return x_;}
	inline int y_size() const { return y_;}
private:
	Canvas(Canvas&);

	Cairo::RefPtr<Cairo::ImageSurface> surface_;
	Cairo::RefPtr<Cairo::Context> cr_;

	int x_, y_;
};

}

#endif //DODO_CANVAS_H

